<style>.footer.footer-home {display: none;}</style>
<div class="header">
    <a href="javascript:history.go(-1); " class="return iconfont icon-shangyiye"></a>
    <div class="header-title">确认信息</div>
</div>
<div class="content content-bot">
    <ul class="content-submit">
        <li>购买数量</li>
        <?php foreach ($output['skus'] as $sku): ?>
        <li>
            <input form="order" type="hidden" name="sku[<?php echo $sku['sku_id']; ?>]" value="<?php echo $sku['num']; ?>">
            <div class="submit-l">
                <label><?php echo $sku['type_name']; ?>: <?php echo $sku['type_desc']; ?></label><br />
                <span>¥<?php echo $sku['sku_price']; ?></span><samp>/张</samp>
            </div>
            <div class="submit-number">× <?php echo $sku['num']; ?></div>
        </li>
        <?php endforeach; ?>
    </ul>
    <form class="visitors" id="order">
        <input type="hidden" name="form_submit" value="ok">
        <input type="hidden" name="sid" value="<?php echo $output['sid'];?>">
        <input type="hidden" name="tid" value="<?php echo $output['tk_id']; ?>">
        <input type="hidden" name="date" value="<?php echo $output['date']; ?>">
        <input type="hidden" name="price_type" value="<?php echo $output['price_type']; ?>">
        <div class="visitors-list">
            <label>游客姓名</label>
            <input type="text" name="name" placeholder="请填写真实姓名" />
            <i class="iconfont icon-jia"></i>
        </div>
        <div class="visitors-list">
            <label>手机号</label>
            <input type="text" name="phone" placeholder="用于接收确认短信" />
            <i class="iconfont "></i>
        </div>
        <div class="visitors-list">
            <label>身份证号</label>
            <input type="text" name="idcard" placeholder="请填写有效证件号码" />
            <i class="iconfont "></i>
        </div>
    </form>
    <div class="submit-remind">注: 玩转六盘水电子消费券密码一经验证即代表消费成功，不可申请退款服务,请您合理安排验证时间。</div>
</div>
<div class="footer footer-submit">
    <ul>
        <li><a><samp>合计：</samp><span>¥<?php echo $output['totalAmount']; ?></span></a></li>
        <li class="active" id="place_order"><a>立即购买</a></li>
    </ul>
</div>
<!-- 支付弹窗 -->
<div class="mask" style="display: none;">
    <div class="payway" onclick=" event.stopPropagation();">
        <p>支付选择：</p>
        <ul>
            <li>
                <a href="javascript:;" class="pay_type_button" >
                    <label for="radio1">
                        <i class="zf zfb"></i>
                        支付宝支付
                        <input type="radio" name="zf" id="radio1" value="ali" class="radio-btn"/>
                        <i class="radio"></i>
                    </label>
                </a>
            </li>
         <li>
                <a href="javascript:;" class="pay_type_button" >
                    <label for="radio2">
                        <i class="zf wx"></i>
                        微信支付
                        <input type="radio" name="zf" id="radio2" class="radio-btn" value="wx"/>
                        <i class="radio"></i>
                    </label>
                </a>
            </li>
        </ul>
        <input type="hidden" name="order_code" value="">
        <input type="hidden" name="pay_type" value="">
        <a href="javascript:;" class="submit-btn">确认提交支付</a>
    </div>

</div>
<div id="sel" style="display: none;position: fixed;top: 0;left: 0;width: 100%;height: 100%;background-color:#fff;"></div>
<link rel="stylesheet" href="resource/css/payway.css?v=0.13" />
<script>
    //打开选择游客信息
    function openSel() {
        $('#sel').load('index.php?act=ticket&op=sel_info').fadeIn();
    }
    //关闭选择游客信息
    function closeSel() {
        $('#sel').fadeOut();
    }
    //打开编辑游客信息
    function openEdit(id) {
        $('#edit').load('index.php?act=ticket&op=update_info&id=' + id).fadeIn();
    }
    //关闭编辑游客信息
    function closeEdit() {
        $('#edit').fadeOut();
    }
    //选择游客信息
    $('.icon-jia').click(function () {
        openSel();
    });



    //支付
    function jsApiCall(json){
        WeixinJSBridge.invoke('getBrandWCPayRequest', json, function (res) {
            if (res.err_msg == 'get_brand_wcpay_request:ok') {
                location.href = 'index.php?act=member&op=order';
            } else {
                popAlert('支付失败,请稍后重新支付', function () {
                    location.href = 'index.php?act=member&op=order';
                });
            }
        });
    }

    //是否正在支付
    var paying = false;
    var orderForm = $('#order');
    $('#place_order').click(function () {
        if ($.trim(orderForm.find('input[name="name"]').val()) == '') {
            popAlert('姓名不能为空');
            return;
        } else if (!/^1\d{10}$/.test(orderForm.find('input[name="phone"]').val())) {
            popAlert('手机号不正确');
            return;
        } else {
            if (paying) {
                return false;
            }
            paying = true;

            <!-- 判断是否微信 --><!-- 暂时默认全部在微信中-->
            <?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false){?>

            $.ajax({
                url: 'index.php?act=order&op=place',
                type: 'POST',
                dataType: 'json',
                //contentType: "application/json",
                data:orderForm.formSerialize(),
                async: false,
                success: function (data, textStatus, jqXHR) {
                    if (data.errcode == 0) {
                        if (data.errmsg == false) {
                            popAlert('订单提交成功', function () {
                                location.href = 'index.php?act=member&op=order';
                            });
                        } else {
                            jsApiCall(data.errmsg);
                        }
                    } else {
                        popAlert(data.errmsg, function () {
                            paying = false;
                        });
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    paying = false;
                }
            });




            <?php } else { ?>
            $('.mask').show();
             <?php  } ?>



        }


    });
    $('.mask').click(function(){
        paying = false;
        $('.mask').hide();
    });
    $('.pay_type_button').click(function(){
        var pay_type= $(this).find('input').val();
        $("[name='pay_type']").val(pay_type);
    });
    $('.submit-btn').click(function(){
        var order_code = $("[name='order_code']").val();
        if($("[name='pay_type']").val()==''){
            alert('请选择您的支付方式！');
            return;
        }
        if($("[name='pay_type']").val() == 'ali'){
            //支付宝支付
            alipay();
        }
        if($("[name='pay_type']").val() == 'wx'){
            //微信支付..
            wxpay();
        }
    });
    function alipay(){
        $.ajax({
            url: 'index.php?act=order&op=place&t=ali',
            type: 'POST',
            data: orderForm.serialize(),
            dataType: 'json',
            async: false,
            success: function (data, textStatus, jqXHR) {
                if (data.errcode == 0) {
                    if (data.errmsg == false) {
                        $('.mask_1').hide();
                        popAlert('支付错误', function () {
                            location.href = 'index.php?act=member&op=order';
                        });
                    } else {
                        window.app && window.app.AppPay(data.errmsg);
                        window.webkit && window.webkit.messageHandlers.AppPay.postMessage(data.errmsg);
                    }
                } else {
                    $('.mask_1').hide();
                    popAlert(data.errmsg, function () {
                        paying = false;
                    });
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                paying = false;
            }
        });
    }

    function wxpay(){
        $.ajax({
            url: 'index.php?act=order&op=place&t=wx',
            type: 'POST',
            data: orderForm.serialize(),
            dataType: 'json',
            async: false,
            success: function (data, textStatus, jqXHR) {
                if (data.errcode == 0) {
                    if (data.errmsg == false) {
                        $('.mask_1').hide();
                        popAlert('支付错误', function () {
                            location.href = 'index.php?act=member&op=order';
                        });
                    } else {
                        window.app && window.app.AppWxPay(JSON.stringify(data.errmsg));
                        window.webkit && window.webkit.messageHandlers.AppWxPay.postMessage(JSON.stringify(data.errmsg));
                    }
                } else {
                    $('.mask_1').hide();
                    popAlert(data.errmsg, function () {
                        paying = false;
                    });
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                paying = false;
            }
        });
    }
    //APP内这边要先弹出选择的支付方式
   /* $.ajax({
        url: 'index.php?act=order&op=place&t=ali',
        type: 'POST',
        data: orderForm.serialize(),
        dataType: 'json',
        async: false,
        success: function (data, textStatus, jqXHR) {
            if (data.errcode == 0) {
                if (data.errmsg == false) {
                    popAlert('支付错误', function () {
                        location.href = 'index.php?act=member&op=order';
                    });
                } else {
                    window.app && window.app.AppPay(data.errmsg);
                    window.webkit && window.webkit.messageHandlers.AppPay.postMessage(data.errmsg);
                }
            } else {
                popAlert(data.errmsg, function () {
                    paying = false;
                });
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            paying = false;
        }
    });*/
</script>